/*
* Copyright (c) 2020 - 2025 Renesas Electronics Corporation and/or its affiliates
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include "hw_sce_ra_private.h"

void HW_SCE_p_func089 (void)
{
    HW_SCE_p_func100(0x53456a36U, 0x70cf1e61U, 0x42dbd0e9U, 0xadead2abU);

    WR1_PROG(REG_B0H, 0x00009438U);
    WR1_PROG(REG_00H, 0x00c0002dU);
    WAIT_STS(REG_04H, 30, 0);
    WR1_PROG(REG_40H, 0x00001800U);
    WR1_PROG(REG_14H, 0x000000a5U);
    WAIT_STS(REG_14H, 31, 1);
    WR1_PROG(REG_2CH, change_endian_long(0x00000001U));

    WR1_PROG(REG_B8H, 0x00000007U);

    WR1_PROG(REG_A4H, 0x06060010U);

    WR1_PROG(REG_A0H, 0x20010001U);
    WAIT_STS(REG_A8H, 0, 1);
    WR1_PROG(REG_ACH, 0x00000001U);

    WR1_PROG(REG_B4H, 0x0038004dU);
    WR1_PROG(REG_B8H, 0x00310007U);

    WR1_PROG(REG_A4H, 0x06060002U);
    WR1_PROG(REG_A0H, 0x20010001U);
    WAIT_STS(REG_A8H, 0, 1);
    WR1_PROG(REG_ACH, 0x00000001U);

    WR1_PROG(REG_B0H, 0x00009454U);
    WR1_PROG(REG_00H, 0x00c00031U);
    WAIT_STS(REG_04H, 30, 0);
    WR1_PROG(REG_40H, 0x00001800U);

    WR1_PROG(REG_B4H, 0x00540085U);
    WR1_PROG(REG_B8H, 0x00380000U);

    WR1_PROG(REG_A4H, 0x06060009U);
    WR1_PROG(REG_A0H, 0x20010001U);
    WAIT_STS(REG_A8H, 0, 1);
    WR1_PROG(REG_ACH, 0x00000001U);

    WR1_PROG(REG_B4H, 0x00540007U);
    WR1_PROG(REG_B8H, 0x003f0000U);

    WR1_PROG(REG_A4H, 0x06060009U);
    WR1_PROG(REG_A0H, 0x20010001U);
    WAIT_STS(REG_A8H, 0, 1);
    WR1_PROG(REG_ACH, 0x00000001U);

    WR1_PROG(REG_B4H, 0x00460031U);
    WR1_PROG(REG_B8H, 0x0077003fU);

    WR1_PROG(REG_A4H, 0x06060015U);
    WR1_PROG(REG_A0H, 0x20010001U);
    WAIT_STS(REG_A8H, 0, 1);
    WR1_PROG(REG_ACH, 0x00000001U);
    WR1_PROG(REG_40H, 0x00000d00U);

    WR1_PROG(REG_B0H, 0x00009415U);
    WR1_PROG(REG_00H, 0x00c0002dU);
    WAIT_STS(REG_04H, 30, 0);
    WR1_PROG(REG_40H, 0x00001800U);
    WR1_PROG(REG_14H, 0x000000a5U);
    WAIT_STS(REG_14H, 31, 1);
    WR1_PROG(REG_2CH, change_endian_long(0x00000001U));

    WR1_PROG(REG_B4H, 0x00150077U);
    WR1_PROG(REG_B8H, 0x00230000U);

    WR1_PROG(REG_A4H, 0x0606000aU);
    WR1_PROG(REG_A0H, 0x20010001U);
    WAIT_STS(REG_A8H, 0, 1);
    WR1_PROG(REG_ACH, 0x00000001U);

    WR1_PROG(REG_40H, 0x00210000U);

    HW_SCE_p_func100(0xc9d7e9d1U, 0x0f3a3742U, 0xc2d64ea9U, 0xdd9cfe98U);
    WR1_PROG(REG_40H, 0x00400000U);

    if (CHCK_STS(REG_40H, 22, 1))
    {
        WR1_PROG(REG_94H, 0x00000800U);

        HW_SCE_p_func101(0xb74cc1c9U, 0x25421297U, 0x97202e89U, 0x6268e01cU);
    }
    else
    {
        HW_SCE_p_func100(0x3f68ae83U, 0x7f650127U, 0x0cd1dfb1U, 0xe14c2718U);
        WR1_PROG(REG_B4H, 0x00150077U);
        WR1_PROG(REG_B8H, 0x00310007U);

        WR1_PROG(REG_A4H, 0x06060002U);
        WR1_PROG(REG_A0H, 0x20010001U);
        WAIT_STS(REG_A8H, 0, 1);
        WR1_PROG(REG_ACH, 0x00000001U);

        WR1_PROG(REG_B0H, 0x0000941cU);
        WR1_PROG(REG_00H, 0x00c0002dU);
        WAIT_STS(REG_04H, 30, 0);
        WR1_PROG(REG_40H, 0x00001800U);
        WR1_PROG(REG_14H, 0x000000a5U);
        WAIT_STS(REG_14H, 31, 1);
        WR1_PROG(REG_2CH, change_endian_long(0x00000002U));

        WR1_PROG(REG_B4H, 0x001c0007U);
        WR1_PROG(REG_B8H, 0x00150000U);

        WR1_PROG(REG_A4H, 0x0606000aU);
        WR1_PROG(REG_A0H, 0x20010001U);
        WAIT_STS(REG_A8H, 0, 1);
        WR1_PROG(REG_ACH, 0x00000001U);

        WR1_PROG(REG_B4H, 0x00150031U);
        WR1_PROG(REG_B8H, 0x001c0007U);

        WR1_PROG(REG_A4H, 0x06060000U);
        WR1_PROG(REG_08H, 0x00020000U);
        WR1_PROG(REG_A0H, 0x20010001U);
        WAIT_STS(REG_A8H, 0, 1);
        WR1_PROG(REG_ACH, 0x00000001U);
        WR1_PROG(REG_40H, 0x00000d00U);

        WR1_PROG(REG_B4H, 0x001c0069U);
        WR1_PROG(REG_B8H, 0x00380007U);

        WR1_PROG(REG_A4H, 0x06060002U);
        WR1_PROG(REG_A0H, 0x20010001U);
        WAIT_STS(REG_A8H, 0, 1);
        WR1_PROG(REG_ACH, 0x00000001U);

        WR1_PROG(REG_B4H, 0x001c0070U);
        WR1_PROG(REG_B8H, 0x003f0007U);

        WR1_PROG(REG_A4H, 0x06060002U);
        WR1_PROG(REG_A0H, 0x20010001U);
        WAIT_STS(REG_A8H, 0, 1);
        WR1_PROG(REG_ACH, 0x00000001U);

        WR1_PROG(REG_94H, 0x0000b400U);
        WR1_PROG(REG_94H, 0x70f7359fU);

        HW_SCE_p_func101(0x672c464dU, 0x947f5ad9U, 0x8592e67aU, 0x6f981feaU);
    }

    WR1_PROG(REG_94H, 0x38008800U);
    WR1_PROG(REG_94H, 0x70f7359fU);
    WR1_PROG(REG_9CH, 0x00000080U);
    WR1_PROG(REG_40H, 0x00A70000U);

    WR1_PROG(REG_94H, 0x00007c07U);
    WR1_PROG(REG_40H, 0x00602000U);
}
